﻿
function getXmlHttp() {
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}
function load_main(tag) {
var req = getXmlHttp()
var contelement = document.getElementById('mainContent')
var statusElem = document.getElementById('statusbar')
req.onreadystatechange = function() {  
         if (req.readyState == 4) { 
            if(req.status == 200) { 
                contelement.innerHTML = req.responseText
            }
        }
		statusElem.style.visibility = "hidden"
    }	
req.open('GET', 'engine/load_data.php?tag='+tag, true)
req.send(null) 
statusElem.style.visibility = "visible"	
}
function add_new(my_form) {
var req = getXmlHttp()
var contelement = document.getElementById('mainContent')
var statusElem = document.getElementById('statusbar')
if (my_form != null) {
	var query = [];
	req.onreadystatechange = function() {  
         if (req.readyState == 4) { 
            if(req.status == 200) { 
                contelement.innerHTML = req.responseText
            }
        }
		statusElem.style.visibility = "hidden"
    }
	req.open('POST', 'engine/add.php', true)
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
	req.send('auth_key='+encodeURIComponent(my_form.auth_key.value)+'&title='+encodeURIComponent(my_form.title.value)+'&text='+encodeURIComponent(my_form.text.value)+'&tags='+encodeURIComponent(my_form.tags.value))
	statusElem.style.visibility = "visible"	
} else {
 	req.onreadystatechange = function() {  
         if (req.readyState == 4) { 
            if(req.status == 200) { 
                contelement.innerHTML = req.responseText
            }
			
        }
		statusElem.style.visibility = "hidden"
    }	
	req.open('POST', 'engine/add.php', true)
	req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
	req.send(null)
	statusElem.style.visibility = "visible"	
}	
}	